package sire.controller;

import sire.dao.BaseDAO;
import sire.ui.SireThinlet;
import sire.ui.SireThinlet.FormType;
import sire.vo.BaseVO;


public class BaseGridSearchController<E extends BaseVO> extends
        BaseGridController<E> {
    
    public BaseGridSearchController(String xml, SireThinlet thin, FormType type,
            BaseDAO dao, String gridName) throws Exception {
        super(xml, thin, type, dao, gridName);
    }
    
    public void filterLike(Object filterComponent) throws InstantiationException, IllegalAccessException{
        Object fieldSearch = "fieldSearch";
        //String col = getParentThinlet().getProperty(filterComponent, fieldSearch).toString();
        String exp = getParentThinlet().getText(filterComponent);
        filterLike(exp);
    }
    
    public void filterLike(String exp)
    throws InstantiationException, IllegalAccessException {
        populateGrid(getDao().getListSearch(exp));
    }
    
    public void filterEquals(Object filterComponent) throws InstantiationException, IllegalAccessException{
        Object fieldSearch = "fieldSearch";
        String col = getParentThinlet().getProperty(filterComponent, fieldSearch).toString();
        String exp = getParentThinlet().getText(filterComponent);
        filterEquals(col, exp);
    }
    
    public void filterEquals(String col, Object exp)
    throws InstantiationException, IllegalAccessException {
        populateGrid(getDao().getListEquals(col, exp));
    }
    
}
